import { reqGetUserInfo } from '@/api/user'

export default {
  state: { userInfo: {} },
  mutations: {
    setUserInfo (state, userInfo) {
      state.userInfo = userInfo
    }
  },
  actions: {
    async getUserInfo (context) {
      const { data } = await reqGetUserInfo()
      console.log(data)
      if (data.code === 0) {
        context.commit('setUserInfo', data.data)
      }
    }
  },
  getters: {
    textAvatar (state) {
      return state.userInfo.username
        ? state.userInfo.username[0].toUpperCase()
        : ''
    }
  },
  modules: {},
  namespaced: true
}
